package controller

import (
	"encoding/json"
	"macaronDev/god"
	"macaronDev/models"
)

type IndexController struct {
	*god.GormAdapter
}

func NewIndexController() *IndexController {
	return &IndexController{}
}

func (this *IndexController) IndexList() string {

	user := models.UserModel{}
	this.Table("users").Where("id=?", 1).Find(&user)
	userStr, _ := json.Marshal(&user)

	return string(userStr)
}

func (this *IndexController) Index() string {
	return "Index"
}

func (this *IndexController) Route(god *god.God) {
	god.Get("/", this.Index)
	god.Get("/a", this.IndexList)
}
